import Request from '@/utils/request'

/**
 * 获取问题列表
 * @param {Object} userid
 * @param {Object} op
 */
export function getGradeList (condition) {
  return new Request({
    url: 'sapi/grade/getProblemGradeListByCondition',
    method: 'post',
    data: condition
  })
}

/**
 * 根据打分问题id获取问题详情
 * @param {Object} pid
 */
export function getGradeDetail (pid, ptype) {
  return new Request({
    url: 'sapi/grade/getProblemGradeDetail',
    method: 'get',
    params: {
      pid: pid,
      ptype: ptype
    }
  })
}

/**
 * 获取考核载体
 */
// eslint-disable-next-line camelcase
export function getCarrierList (is_add) {
  return new Request({
    url: 'sapi/grade/get-check-list',
    method: 'get',
    params: {
      is_add: is_add
    }
  })
}

/**
 * 获取指定载体考核项详情
 * @param {Object} carrierId
 */
// eslint-disable-next-line camelcase
export function getCarrierDetail (carrierId, is_add) {
  return new Request({
    url: 'sapi/grade/check-item-detail',
    method: 'get',
    params: {
      checkitemid: carrierId,
      is_add: is_add
    }
  })
}

/**
 * 更新问题信息
 * @param {Object} submitObj
 */
export function updateProblemInst (submitObj) {
  return new Request({
    url: 'sapi/grade/updateProblemGradeInfo',
    method: 'post',
    data: {
      op: submitObj.op,
      opcontent: submitObj.opcontent,
      problem_inst: submitObj.problem_inst
    }
  })
}

/**
 * 获取考核部门列表
 * @param {Object} dept_type 部门类型。0: 打分考核部门；1：被打分考核部门
 */
export function getCheckDeptList (assessType, depart) {
  return new Request({
    url: 'sapi/grade/getCheckDeptList',
    method: 'get',
    params: {
      problem_type: assessType,
      depart: depart
    }
  })
}

/**
 * 变更打分部门
 * @param {Object} pid
 * @param {Object} dept
 */
export function changeAssessmentDept (pid, dept) {
  return new Request({
    url: 'sapi/grade/changeAssessmentDept',
    method: 'post',
    data: {
      id: pid,
      assessment_dept: dept
    }
  })
}

/**
 * 获取加分列表
 */
export function getAddApplyList (condition) {
  return new Request({
    url: 'sapi/grade/getAddApplyList',
    method: 'post',
    data: condition
  })
}

/**
 * 获取加分申请详情
 * @param {Object} applyid
 */
export function getAddApplyDetail (applyid) {
  return new Request({
    url: 'sapi/grade/getAddApplyDetail',
    method: 'get',
    params: {
      applyid: applyid
    }
  })
}

/**
 * 加分申请流转提交
 * @param {Object} submitObj
 */
export function updateApplyInst (submitObj) {
  return new Request({
    url: 'sapi/grade/updateApplyInst',
    method: 'post',
    data: submitObj
  })
}

/**
 * 获取评分统计信息
 * @param {Object} condition
 */
export function getSubDeptStat (condition) {
  return new Request({
    url: 'sapi/grade/getSubDeptGradeStat',
    method: 'get',
    params: condition
  })
}

/**
 * 获取考核概览信息
 * @param condition
 * @returns {*}
 */
export function getApproveStat (condition) {
  return new Request({
    url: 'sapi/grade/getGradeApproveStat',
    method: 'get',
    params: condition
  })
}

/**
 * 打分问题批量操作
 * @param submitObj
 * @returns {*}
 */
export function batchUpdateProblem (submitObj) {
  return new Request({
    url: 'sapi/grade/batchUpdateProblemGradeInfo',
    method: 'post',
    data: submitObj
  })
}
